package com.lingjtx.im.core.config;

import com.lingjtx.common.thread.api.WebClientApi;
import com.lingjtx.common.thread.config.ObjectPoolTemplateConfig;
import com.lingjtx.common.thread.pooling.ObjectPoolTemplate;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.web.reactive.function.client.WebClient;

@Configuration
public class ImNetworkConfig {

    @Bean("webClientObjectPoolTemplate")
    public ObjectPoolTemplate<WebClient> webClientObjectPoolTemplate(ObjectPoolTemplateConfig config) {
        return config.webClientObjectPoolTemplate();
    }

    @Bean
    public WebClientApi webClientApi(ObjectPoolTemplateConfig config) {
        return config.webClientApi();
    }

    @Primary
    @Bean
    public MeterRegistry noOpMeterRegistry() {
        return new SimpleMeterRegistry(); // 或使用 new NoopMeterRegistry()，更轻量
    }
}
